双击PDB文件用Pymol打开
使用 macOS 自动操作(Automator) 来创建一个 .app
,使 .pdb
文件在双击时用 /opt/anaconda3/bin/pymol
打开,并且支持多开 PyMOL。以下是完整的步骤:
步骤 1:创建 Shell 脚本
-
打开终端 (Terminal)
-
创建
open_pymol.sh
文件nano ~/open_pymol.sh
-
在文件中添加以下内容
#!/bin/bash nohup /opt/anaconda3/bin/pymol "$@" >/dev/null 2>&1 & disown
解释:
nohup
让进程独立运行,不受终端关闭影响。"$@"
代表传递所有参数,即.pdb
文件路径。>/dev/null 2>&1 &
让进程后台运行,不输出信息。disown
让 PyMOL 进程与 shell 脱钩,支持多开。
-
保存文件:
- 按
Ctrl + X
,然后按Y
,最后按回车。
- 按
-
赋予执行权限
chmod +x ~/open_pymol.sh
步骤 2:使用 Automator 创建 macOS App
-
打开 Automator
- 按
Cmd + Space
,搜索 Automator 并打开。
- 按
-
创建新文档
- 选择 “应用程序” (Application),然后点击 选择 (Choose)。
-
添加“运行 Shell 脚本”
- 在 Automator 左侧搜索 “运行 Shell 脚本” (Run Shell Script),然后拖到右侧的工作区域。
-
修改 Shell 脚本设置
- Shell:选择
/bin/bash
- 传递输入 (Pass input):选择 作为参数 (as arguments)
- Shell:选择
-
在文本框中输入以下内容
~/open_pymol.sh "$@"
-
保存 Automator 应用
- 点击 文件 (File) > 另存为 (Save)
- 取名为 PyMOL Launcher
- 存放在
/Applications/
目录或~/Applications/
- 格式 (File Format) 选择 “应用程序” (Application)
步骤 3:设置 .pdb
文件默认打开方式
- 找到一个
.pdb
文件 - 右键 > 显示简介 (Get Info)
- 在“打开方式” (Open With) 选择
PyMOL Launcher.app
- 点击“全部更改” (Change All)
测试
- 双击
.pdb
文件,看看是否能够自动用/opt/anaconda3/bin/pymol
打开,并且支持多开! - 如果 PyMOL 能够正常打开
.pdb
文件,并且不会弹出 “Pymol.app 已完成 0%” 的窗口,那么说明配置成功!